package com.moxiao.yfjh.module.blind.dal.mysql.level;

import com.moxiao.yfjh.module.blind.controller.admin.level.vo.BlindMemberLevelExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.level.vo.BlindMemberLevelPageReqVO;
import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.blind.dal.dataobject.level.BlindMemberLevelDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.blind.controller.admin.level.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲会员等级 Mapper
 *
 * @author mx
 */
@Mapper
public interface BlindMemberLevelMapper extends BaseMapperX<BlindMemberLevelDO> {

    default PageResult<BlindMemberLevelDO> selectPage(BlindMemberLevelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlindMemberLevelDO>()
                .eqIfPresent(BlindMemberLevelDO::getNo, reqVO.getNo())
                .likeIfPresent(BlindMemberLevelDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberLevelDO::getMemberNum, reqVO.getMemberNum())
                .betweenIfPresent(BlindMemberLevelDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(BlindMemberLevelDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlindMemberLevelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindMemberLevelDO::getId));
    }

    default List<BlindMemberLevelDO> selectList(BlindMemberLevelExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlindMemberLevelDO>()
                .eqIfPresent(BlindMemberLevelDO::getNo, reqVO.getNo())
                .likeIfPresent(BlindMemberLevelDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberLevelDO::getMemberNum, reqVO.getMemberNum())
                .betweenIfPresent(BlindMemberLevelDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(BlindMemberLevelDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlindMemberLevelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindMemberLevelDO::getId));
    }
    @Select("select count(*) num from blind_member_level where no = #{levelNo}")
    Integer getMemberLevelNo(@Param("levelNo") String levelNo);

}
